package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class VALORFactory extends AbstractTokenVisitorFactory {

	private static VALORFactory INSTANCE;
	
	private VALOR1Factory valor1Factory;
	private VALOR2Factory valor2Factory;
	
	public static VALORFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new VALORFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() {
			initializer = NoOperationInitializer.getInstance();
			valor1Factory = VALOR1Factory.getInstance();
			valor2Factory = VALOR2Factory.getInstance();
		}
	};
	
	private VALORFactory() throws Exception {
		initializer.init();
	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		return valor1Factory.makeChainedVisitor(valor2Factory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		return valor1Factory.makeChainedVisitor(valor2Factory.makeVisitor());
	}
	
	
}
